<% if @project.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@project.errors.count, "error") %> </h2>

      <ul>
      <% @project.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>
  
<h3>프로젝트 새로 만들기</h3>

<%= form_for(@project) do |f| %>
  
  <div class="field">
    <%= f.label :name, "프로젝트명" %>
    <%= f.text_field :name %>
    <%= f.submit "새로 만들기" %>
  </div>
 
<% end %>


<hr/>

<h3>프로젝트 가입</h3>
<p>아래 프로젝트들중 참여하고싶은 프로젝트를 선택하세요.</p>
 
<%= form_tag new_project_path, :method => 'get' do %>
  <p>
  	<%= select_tag(:field, options_for_select([['프로젝트명', 'name'],['프로젝트ID', 'id']])) %>
    <%= text_field_tag :search, params[:search] %>
    <%= submit_tag "찾기", :name => nil %>
  </p>
<% end %>

<%= form_for(@project,  :url => { :action => "join_project" }, :method => :post) do |f| %>
  
  
  <table class="table table-hover">
  <thead>
    <tr>
   	  <th>선택</th>
      <th>ID</th>
   	  <th>프로젝트명</th>
   	  <th>Owner</th>
      <th>개설일</th>
     </tr>
  </thead>

  <tbody>
    <% @projects.each do |project| %>
      <tr>
      	<td><%= radio_button_tag "project_id", project.id %></td>
      	<td><%= link_to project.id, project_path(project) %></td>
        <td><%= link_to project.name, project_path(project) %></td>
        <td><%= project.owner.name %></td>
        <td><%= project.created_at %></td>
        
      </tr>
    <% end %>
</table>

	<%= paginate @projects, :params => {:controller => 'projects', :action => 'new'} %>

   <%= f.submit "가입하기", :class => "btn btn-primary"  %> <%= link_to '내 프로젝트 보기', projects_path, :class => "btn btn-info" %>
  
 
<% end %>

